package models

import "errors"

type Role struct {
	ID          int    `gorm:"primaryKey"`
	Name        string `gorm:"size:50;unique"`
	Description string `gorm:"size:255"`
}

// GetRoleIDByName 根据角色名获取 role_id
func GetRoleIDByName(name string) (int, error) {
	var role Role
	if err := DB.Where("name = ?", name).First(&role).Error; err != nil {
		return 0, errors.New("role not found")
	}
	return role.ID, nil
}
